bitkeeper revision 1.1180 (420ca6f6iwPf_PBxj1CWyA2TtgM19w)
authorsos22@douglas.cl.cam.ac.uk <sos22@douglas.cl.cam.ac.uk>
Fri, 11 Feb 2005 12:37:10 +0000 (12:37 +0000)
committersos22@douglas.cl.cam.ac.uk <sos22@douglas.cl.cam.ac.uk>
Fri, 11 Feb 2005 12:37:10 +0000 (12:37 +0000)
Get rid of cdb_trap, and replace it with a new function ``call_with_registers''.

Signed-off-by: sos22@cl.cam.ac.uk.
xen/arch/x86/cdb.c
xen/arch/x86/x86_32/cdb_trap.S
xen/include/asm-x86/debugger.h

index 33e516628bc23ae47ea3e78aa9a21327059b8927..5a3d3e2188c9a20fd983001a96ca1043b6e6f4e5 100644 (file)
@@ -219,7 +219,7 @@ handle_register_read_command(struct xen_regs *regs, struct xendbg_context *ctx)
        char buf[121];
 
        sprintf(buf,
-               "%.08x%.08x%.08x%.08x%.08x%.08x%.08x%.08x%.08x%.08x%.08x%.08x%.08x%.08x%.08x",
+               "%.08x%.08x%.08x%.08x%.08x%.08x%.08x%.08x%.08x%.08x%.08x%.08x%.08x%.08x%.08x%.08x",
                bswab32(regs->eax),
                bswab32(regs->ecx),
                bswab32(regs->edx),
@@ -232,6 +232,7 @@ handle_register_read_command(struct xen_regs *regs, struct xendbg_context *ctx)
                bswab32(regs->eflags),
                bswab32(regs->cs),
                bswab32(regs->ss),
+               bswab32(regs->ds),
                bswab32(regs->es),
                bswab32(regs->fs),
                bswab32(regs->gs));
@@ -328,7 +329,7 @@ __trap_to_cdb(struct xen_regs *regs)
 
        if (xdb_ctx.serhnd < 0) {
                dbg_printk("Debugger not ready yet.\n");
-               return;
+               return 0;
        }
 
        /* We rely on our caller to ensure we're only on one processor
@@ -346,7 +347,7 @@ __trap_to_cdb(struct xen_regs *regs)
        if (!atomic_dec_and_test(&xendbg_running)) {
                printk("WARNING WARNING WARNING: Avoiding recursive xendbg.\n");
                atomic_inc(&xendbg_running);
-               return;
+               return 0;
        }
 
        smp_send_stop();
@@ -385,6 +386,7 @@ __trap_to_cdb(struct xen_regs *regs)
        watchdog_on = old_watchdog;
        atomic_inc(&xendbg_running);
        local_irq_restore(flags);
+       return 0;
 }
 
 static int
index dfae4c5e42d447550f4a8835f42765a9a57950c2..71b5b73eeadfdc73fd1cda272b1a2e00105dbbe8 100644 (file)
@@ -1,36 +1,36 @@
-.global cdb_trap
-.extern __trap_to_cdb
-       
-#define SAVE_ALL_NOSEGREGS \
-       pushw $0;  \
-        pushw %gs; \
-       pushw $0;  \
-        pushw %fs; \
-       pushw $0;  \
-        pushw %es; \
-       pushw $0;  \
-        pushw %ds; \
-        pushl %eax; \
-        pushl %ebp; \
-        pushl %edi; \
-        pushl %esi; \
-        pushl %edx; \
-        pushl %ecx; \
-        pushl %ebx;
+.global call_with_registers
 
-       // Save the register state and call __trap_to_cdb
-cdb_trap:
-       pushw $0
-       pushw %ss
-       pushl %esp //We'll fix this up later, in __trap_to_cdb, by adding 8
+#include <asm/asm-offsets.h>
+
+       // int call_with_registers(void (*f)(struct xen_regs *r)) ->
+       // build a xen_regs structure, and then call f with that.
+call_with_registers:
        pushf
-       pushw $0
-       pushw %cs
-       pushl 16(%esp)
-1:     pushl $0                // Orig_eax
-       SAVE_ALL_NOSEGREGS
+       subl $XREGS_user_sizeof, %esp
+       movl %ebx, XREGS_ebx(%esp)
+       movl %ecx, XREGS_ecx(%esp)
+       movl %edx, XREGS_edx(%esp)
+       movl %esi, XREGS_esi(%esp)
+       movl %edi, XREGS_edi(%esp)
+       movl %ebp, XREGS_ebp(%esp)
+       movl %eax, XREGS_eax(%esp)
+       movw $0, XREGS_error_code(%esp)
+       movw $0, XREGS_entry_vector(%esp)
+       movl XREGS_user_sizeof+4(%esp), %eax
+       movl %eax, XREGS_eip(%esp)
+       movl %cs, XREGS_cs(%esp)
+       movl XREGS_user_sizeof(%esp), %eax
+       movl %eax, XREGS_eflags(%esp)
+       movl %esp, XREGS_esp(%esp)
+       addl $XREGS_user_sizeof+4, XREGS_esp(%esp)
+       movl %ss, XREGS_ss(%esp)
+       movl %es, XREGS_es(%esp)
+       movl %ds, XREGS_ds(%esp)
+       movl %fs, XREGS_fs(%esp)
+       movl %gs, XREGS_gs(%esp)
+
+       movl XREGS_user_sizeof+8(%esp), %eax
        pushl %esp
-       call __trap_to_cdb
-       add $72, %esp
-       xorl %eax, %eax
+       call *%eax
+       add $XREGS_user_sizeof + 8, %esp
        ret
index 62828329b8ccefabb5535ef9d60ec7115bd9b959..d09a1264fcb16d8d4798284f6b571d2c3dd849b6 100644 (file)
@@ -38,6 +38,8 @@
 #define DEBUGGER_trap_fatal(_v, _r) \
     if ( debugger_trap_fatal(_v, _r) ) return EXCRET_fault_fixed;
 
+int call_with_registers(int (*f)(struct xen_regs *r));
+
 #ifdef XEN_DEBUGGER
 
 #include <asm/pdb.h>
@@ -105,11 +107,10 @@ static inline int debugger_trap_fatal(
 
 #elif defined(CRASH_DEBUG)
 
-extern void cdb_trap(void);
-extern void __trap_to_cdb(struct xen_regs *);
+extern int __trap_to_cdb(struct xen_regs *r);
 #define debugger_trap_entry(_v, _r) (0)
-#define debugger_trap_fatal(_v, _r) (__trap_to_cdb(_r), 0)
-#define debugger_trap_immediate() (cdb_trap())
+#define debugger_trap_fatal(_v, _r) __trap_to_cdb(_r)
+#define debugger_trap_immediate() call_with_registers(__trap_to_cdb)
 
 #elif 0